package com.thrd.taiexhibition.activity;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.thrd.basicframework.bean.BaseRecyclerAdapter;
import com.thrd.taiexhibition.R;
import com.thrd.taiexhibition.adapter.ThemeIndustryHomeAdapter;
import com.thrd.taiexhibition.base.BackTitleActivity;
import com.thrd.taiexhibition.bean.BeanThemeIe;
import com.thrd.taiexhibition.bean.BeanThemeIndustry;
import com.thrd.taiexhibition.bean.BeanThemeResource;
import com.thrd.taiexhibition.fresco.FrescoImage;
import com.thrd.taiexhibition.fresco.FrescoUtils;
import com.thrd.taiexhibition.presener.ThemeIndustryHomePresener;
import com.thrd.taiexhibition.ui.TimeADView;
import com.thrd.taiexhibition.view.ThemeIndustryHomeView;

/**
 * @author: ${唐杰}
 * @date: 2021/3/24
 * 城市产业展介绍
 */
@Route(path = "/app/tiha",group = "app")
public class ThemeIndustryHomeActivity extends BackTitleActivity implements ThemeIndustryHomeView {

    @Autowired(name="id")
    long id;
    private FrescoImage mFrescoImage;
    private RecyclerView mRecyclerView;
    private ThemeIndustryHomeAdapter mAdapter;
    private FrescoImage mFrescoApplet;
    private FrescoImage mFrescoClient;
    private TextView mTitleName;
    private TextView mContent;
    private TextView mInfoText;
    private TextView mSkip;
    private TimeADView mTimeADView;

    @Override
    protected int getLayout() {
        return R.layout.activity_theme_industry_home;
    }

    @Override
    protected void initView() {
        mSkip = (TextView) findViewById(R.id.tv_skip);
        mInfoText = (TextView) findViewById(R.id.tv_info_text);
        mTitleName = (TextView) findViewById(R.id.tv_title_name);
        mContent = (TextView) findViewById(R.id.tv_content);
        mFrescoApplet = (FrescoImage) findViewById(R.id.fi_image_applet);
        mFrescoClient = (FrescoImage) findViewById(R.id.fi_image_client);
        mFrescoImage = (FrescoImage) findViewById(R.id.fi_image_bg);
        mRecyclerView = (RecyclerView) findViewById(R.id.rv_recyclerview);
        mTimeADView = (TimeADView) findViewById(R.id.tadv_ad);
        LinearLayoutManager manager= new LinearLayoutManager(this);
        manager.setOrientation(RecyclerView.HORIZONTAL);
        mRecyclerView.setLayoutManager(manager);
    }

    @Override
    protected void initData() {
        mAdapter = new ThemeIndustryHomeAdapter(this,null);
        mRecyclerView.setAdapter(mAdapter);

        ThemeIndustryHomePresener mThemeIndustryHomePresener=new ThemeIndustryHomePresener(this);
        mThemeIndustryHomePresener.getCityFocusData(id);


    }

    @Override
    protected void initEvent() {
        mAdapter.setItemClick(new BaseRecyclerAdapter.ItemClick<BeanThemeResource>() {
            @Override
            public void onItemClick(int p, BeanThemeResource e) {

            }
        });

        mSkip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //跳全景图
//                ARouter.getInstance().build("/app/panoramic").navigation();
                ARouter.getInstance().build("/app/enterprise") .navigation();
            }
        });
    }


    @Override
    public void onError(String error, int type) {

    }

    @Override
    public void onSuccess(BeanThemeIndustry mBeanThemeHome) {
        BeanThemeIe mBeanThemeIe =mBeanThemeHome.getThIndustryExhibit();
        mTimeADView.setData(mBeanThemeIe.getIemovecoverimgs(),5);
        mAdapter.refresh(mBeanThemeHome.getThIeResourceList());
        FrescoUtils.getInstance().setPrefixProgressLoad(this,mFrescoApplet,mBeanThemeIe.getIeappletqrcode());
        FrescoUtils.getInstance().setPrefixProgressLoad(this,mFrescoClient,mBeanThemeIe.getIeclientqrcode());
        mTitleName.setText(TextUtils.isEmpty(mBeanThemeIe.getIeintro())?"":mBeanThemeIe.getIeintro());
        mContent.setText(TextUtils.isEmpty(mBeanThemeIe.getIeintrodetail())?"":mBeanThemeIe.getIeintrodetail());
        mInfoText.setText(TextUtils.isEmpty(mBeanThemeIe.getIebottomcontent())?"":mBeanThemeIe.getIebottomcontent());
        FrescoUtils.getInstance().setPrefixProgressLoad(this,mFrescoImage,mBeanThemeIe.getIeContentBackImg());
    }
}
